Skip to content

sensors: one catalogue for every machine, and the infinity3 boards' own sensors - #224

Merged
dimerr merged 3 commits into
OpenIPC:masterfrom
dimerr:image-sensor-catalogue
Nov 4, 2026
Merged

dimerr merged 3 commits into
OpenIPC:masterfrom
dimerr:image-sensor-catalogue

Conversation

@dimerr

@dimerr dimerr commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Sensors are the same parts on every SoC, but each family kept its own table of names, addresses and IDs. This replaces those tables with one catalogue, and uses it to get the MSC313E/MSC316 retail dumps running with their real sensors.

  • hw/i2c/image-sensor.c: one catalogue; machines call image_sensor_create(bus, name). Replaces the tables in hisilicon, sigmastar, ingenic, fullhan, goke, grainmedia and novatek. Xiongmai takes catalogue names alongside QOM types. An unknown name lists the catalogue.
  • Build: sensor models now build for every target (setup.sh), so sensor=imx307 works on a T31 and sensor=gc4653 on a Hi3516EV300. Existing trees are migrated.
  • image-sensor QOM interface: exposure from any sensor, so the infinity3 ISP is no longer limited to SOI parts. Implemented by the F37 family, hisi-smartsens, hisi-imx307, imx323, galaxycore-sensor and ingenic-ov2735 (the last two report rows and gain only). Not yet by the other Sony models, hisi-mis2006 or hisi-sp2305, which have no exposure decode: on the infinity3 ISP they are detected but draw nothing. The Ingenic ISPs keep their per-family calls on purpose.
  • hisi-gc2053 removed: galaxycore-sensor answers for the same part.
  • New: SC2310, SC2235, SC5035, SC5238 and IMX323 (new model), with IDs from the vendor drivers' Sensor_id_table; SC2310's gain and half-row exposure from pCus_GetAEGain/pCus_SetAEUSecs; rtc=ds1338 on the sigmastar machines.

Boards (msc313e)

Board Options Result
Anjoy YM200J sensor=imx307 H.264 RTP received over RTSP, AE converges
Anjoy YM200J2 sensor=imx307 no reboot loop, AE converges
Anjoy MC300E10 sensor=sc2315e no reboot loop, AE converges
Raysharp MSC316D sensor=sc2310,rtc=ds1338 -m 128M no watchdog resets, AE converges
Jabsco C3001 default unchanged
MSC316DC sensor=imx323 -m 128M stable, but see below

The reboots and resets were the firmware not finding its sensor. The MSC316 boards also need 128 MiB: at 64 MiB the kernel's CMA pool wraps onto low memory. Details are in docs/sigmastar.md.

Known gaps

  • MSC316DC/IMX323: the picture saturates (mean Y 255) and AE does not settle; cause not found. The driver's 0.3 dB gain step is confirmed, but that it lands in 0x301E comes from the init table, not the gain code. The app also still loops on P2PID_GET.
  • sc2315e fine gain: 1x = 0x10 comes from the driver's gain_reg defaults; its decode was not traced in full. Same for sc5035/sc5238, which have IDs but the SC2336 gain decode.
  • Only RTP packets, SDP and ISP statistics were checked, not decoded pictures.

Test plan

  • 20 self-contained device suites, identical to baseline, plus new catalogue and rtc= tests in test-sigmastar.py
  • sofia-isp-ci-test.sh: Sofia reaches ISP Dev 0 running with sensor=sc2315e and the new 0x3109 value
  • Firmware boots: test-fullhan-boot (fh8852v200, fh8852v100), test-grainmedia-boot (gm8136, gm8135), test-novatek-boot (nt98566, nt98562, with sensor=sc401ai), test-ingenic-boot --mode kernel (t20, t23, t31, t40)
  • OpenIPC ipcinfo on hi3516ev300: same detection as baseline for gc2053, sc2315e, imx307; gc4653 newly detected; sc2335 detected on hi3516ev200
  • Goke firmware boot: not run (needs a HAL/flash dump locally); covered only by test-gk710x.py
  • Allwinner firmware boot with the catalogue's gc2053: not run; covered only by test-allwinner-cam.py
  • Full CI boot matrix

…wn sensors

A sensor is the same part on any SoC, but each family kept its own table
of names, addresses and IDs, so a part existed only where someone had
typed it in.  hw/i2c/image-sensor.c is now the one catalogue: a machine
calls image_sensor_create(bus, name) and takes any part in it.  It
replaces the tables in hisilicon, sigmastar, ingenic, fullhan, goke,
grainmedia and novatek; xiongmai takes its names beside QOM types, and
allwinner uses it for its GC2053.  The sensor models build for every
target.  hisi-gc2053 goes: galaxycore-sensor is the same part.

The image-sensor interface gives an ISP a sensor's exposure whatever its
family, so the infinity3 ISP no longer draws only from SOI parts.
hisi-f37 and its family, hisi-smartsens, hisi-imx307 and imx323 have it.
The Ingenic ISPs keep their per-family calls.

For the MSC313E and MSC316 boards, with IDs from the vendor drivers:

* SC2310, SC2235, SC5035, SC5238, IMX323 (new model); hisi-imx307 reads
  back the two registers the MStar driver's ID table checks; sc2315e
  reads 0x20 at 0x3109, as that driver's table has it
* SC2310's gain and half-row exposure, from pCus_GetAEGain and
  pCus_SetAEUSecs; the SC2336's decoder does not apply
* rtc=ds1338: the DS1307-family RTC the Raysharp app reads at 0xD0

Firmware that rebooted or died under its watchdog did so for want of its
sensor, or of its RAM (docs/sigmastar.md, Boards).
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Share image sensors across machines and support Infinity3 board sensors

✨ Enhancement 🐞 Bug fix 🧪 Tests 📝 Documentation 🕐 40+ Minutes

Grey Divider

AI Description

• Replace machine-specific sensor tables with one catalogue so boards can select any available
 model.
• Add Infinity3 sensor IDs, exposure support, and an optional RTC for retail firmware boots.
• Build sensor models across targets and test catalogue selection, addresses, and RTC attachment.
Diagram

graph TD
  Setup["Target build"] --> Catalogue["Sensor catalogue"] --> Models["I2C sensor models"] --> Interface["Exposure interface"] --> ISP["Infinity3 ISP"]
  Machines["Machine boards"] --> Catalogue
  Machines --> ISP
  Machines --> RTC["Optional RTC"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Define a QOM subtype for every sensor part
  • ➕ Keep each part's ID and address near its model.
  • ➕ Allow part-specific behavior without catalogue property branches.
  • ➖ Create many near-identical types for parts sharing register behavior.
  • ➖ Require more model code to add an otherwise data-only variant.

Recommendation: Keep the shared catalogue for variants that differ mainly in address and probe properties, and use dedicated models when register behavior differs, as with IMX323. Per-part QOM types would make simple additions more costly; review the catalogue and build-list migration together to ensure every named model is available.

Files changed (21) +604 / -396

Enhancement (9) +503 / -46
sigmastar.cAttach catalogue sensors and an optional board RTC +38/-40

Attach catalogue sensors and an optional board RTC

• Replaces Sigmastar's local sensor table while retaining the Infinity3 ISP sensor link. Adds rtc=ds1338 on the first I2C bus and rejects unsupported RTC names.

qemu/hw/arm/sigmastar.c

xiongmai.cAccept catalogue names alongside Xiongmai QOM sensor types +6/-0

Accept catalogue names alongside Xiongmai QOM sensor types

• Creates known catalogue sensors with an optional address override. Existing direct QOM-type selection remains available.

qemu/hw/arm/xiongmai.c

hisi-f37.cExpose F37-family measurements through image-sensor +20/-0

Expose F37-family measurements through image-sensor

• Adapts the existing SOI exposure calculation to the new interface. Derived F37-family models inherit that implementation.

qemu/hw/i2c/hisi-f37.c

hisi-imx307.cAdd IMX307 probe values and exposure decoding +30/-0

Add IMX307 probe values and exposure decoding

• Adds register values checked by the MStar driver. Implements image-sensor exposure using shutter, frame-length, gain, and output-size registers.

qemu/hw/i2c/hisi-imx307.c

hisi-smartsens.cSupport SmartSens frame measurements and SC2310 gain +46/-0

Support SmartSens frame measurements and SC2310 gain

• Adds image-sensor exposure reporting with frame length and output dimensions. A configurable fine-gain baseline enables SC2310-style gain and half-row exposure decoding without changing the existing Ingenic helper.

qemu/hw/i2c/hisi-smartsens.c

image-sensor.cIntroduce the shared image-sensor catalogue +177/-0

Introduce the shared image-sensor catalogue

• Centralizes sensor names, models, addresses, IDs, and variant properties, including new SmartSens entries. Provides creation, name-checking, unknown-name reporting, and exposure-interface dispatch.

qemu/hw/i2c/image-sensor.c

imx323.cModel the IMX323 I2C sensor +124/-0

Model the IMX323 I2C sensor

• Adds a register-backed IMX323 model with its driver-checked ID and image-sensor exposure calculation. The model reads frame and shutter timing from IMX323-specific registers.

qemu/hw/i2c/imx323.c

sstar-i3-isp.cRead Infinity3 exposure through the generic interface +10/-6

Read Infinity3 exposure through the generic interface

• Replaces the SOI-only exposure call so the ISP can render from supported SmartSens and Sony models. Adds trace output when the sensor window cannot cover the requested crop.

qemu/hw/misc/sstar-i3-isp.c

image-sensor.hDeclare catalogue and exposure-interface APIs +52/-0

Declare catalogue and exposure-interface APIs

• Defines shared exposure measurements, the QOM interface, catalogue lookup, and sensor creation with an optional address override.

qemu/include/hw/i2c/image-sensor.h

Refactor (7) +24 / -288
allwinner-v83x.cAttach the Allwinner GC2053 through the catalogue +2/-2

Attach the Allwinner GC2053 through the catalogue

• Replaces direct creation of hisi-gc2053 with the catalogue's gc2053 entry on TWI1.

qemu/hw/arm/allwinner-v83x.c

fullhan.cReplace FullHan's sensor table with catalogue lookup +3/-47

Replace FullHan's sensor table with catalogue lookup

• Removes local sensor specifications and construction logic. The first I2C bus now creates the selected or default sensor through the shared catalogue.

qemu/hw/arm/fullhan.c

goke.cRoute Goke sensor selection through the catalogue +4/-25

Route Goke sensor selection through the catalogue

• Removes Goke's three-entry sensor table and uses shared creation on IDC 0.

qemu/hw/arm/goke.c

grainmedia.cReplace GrainMedia's sensor factory with shared creation +2/-36

Replace GrainMedia's sensor factory with shared creation

• Removes local OmniVision IDs and device-property setup. Sensor selection now uses the common catalogue on the GrainMedia I2C bus.

qemu/hw/arm/grainmedia.c

hisilicon.cReplace HiSilicon's I2C sensor selection chain +3/-84

Replace HiSilicon's I2C sensor selection chain

• Uses catalogue creation in place of the machine's name-to-model chain. The separate SSI sensor path remains in the machine.

qemu/hw/arm/hisilicon.c

novatek.cUse catalogue sensor IDs on Novatek boards +5/-27

Use catalogue sensor IDs on Novatek boards

• Removes Novatek's local SmartSens ID table and instantiates the selected sensor through the shared catalogue.

qemu/hw/arm/novatek.c

ingenic.cUse shared creation for Ingenic's sensor buses +5/-67

Use shared creation for Ingenic's sensor buses

• Removes Ingenic's local catalogue and factory. Primary, secondary, tertiary, and GPIO-backed I2C sensor paths now use shared creation while the ISP's existing per-family calls remain unchanged.

qemu/hw/mips/ingenic.c

Tests (1) +27 / -0
test-sigmastar.pyTest catalogue selection and DS1338 attachment +27/-0

Test catalogue selection and DS1338 attachment

• Checks representative sensor models and I2C addresses in the QEMU device tree. Also verifies unknown-name reporting and rtc=ds1338 placement at address 0x68.

qemu/tests/test-sigmastar.py

Documentation (3) +35 / -8
CLAUDE.mdDocument the shared sensor architecture +13/-7

Document the shared sensor architecture

• Replaces machine-specific sensor guidance with instructions for adding parts to the catalogue and implementing exposure through the image-sensor interface. Notes Xiongmai's QOM-type option and the separate SSI IMX122 path.

CLAUDE.md

allwinner-v83x.mdCorrect the Allwinner GC2053 model reference +1/-1

Correct the Allwinner GC2053 model reference

• Identifies the catalogue-backed GalaxyCore model used on TWI1 instead of the removed hisi-gc2053 model.

docs/allwinner-v83x.md

sigmastar.mdDocument Infinity3 board sensor, RAM, and RTC options +21/-0

Document Infinity3 board sensor, RAM, and RTC options

• Adds observed board configurations and explains how missing sensors or insufficient RAM affect firmware boots. Documents the DS1338 option and the unresolved IMX323 picture saturation.

docs/sigmastar.md

Other (1) +15 / -54
setup.shBuild sensor models across I2C targets +15/-54

Build sensor models across I2C targets

• Installs the new catalogue, interface header, and IMX323 model; moves shared sensor sources from family-specific build lists to CONFIG_I2C. Removes obsolete hisi-gc2053 references, migrates existing lists, and selects DS1338 for Sigmastar.

qemu/setup.sh

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Remediation recommended

1. GalaxyCore sensors cannot feed exposure to ISP models ✓ Resolved
Description
image_sensor_create accepts catalogue-selected GalaxyCore parts (gc2053, gc4653, gc2093, and
others) on SigmaStar, but galaxycore-sensor does not implement the image-sensor interface. When
infinity3 calls image_sensor_exposure() for one of these detectable devices, it returns false,
and the ISP declines to generate a frame.

2. Clock options are ignored on three machines ✓ Resolved
Description
sigmastar_common_init validates and creates the requested RTC only inside its c->miic branch,
while the no-MIIC branch checks only sms->sensor. On ssr621q, ssd202d, and ssd201, which
have no configured MIIC buses, both rtc=ds1338 and invalid names such as rtc=foo are accepted
without a message or an attached RTC.

3. Existing build trees never get the RTC model enabled ✓ Resolved
Description
setup.sh adds select DS1338 to a fresh config SIGMASTAR block but omits it from the symbol
repair loop for existing blocks. On an already-patched tree where nothing else enables DS1338,
rtc=ds1338 reaches i2c_slave_create_simple(bus[0], "ds1338", 0x68) with no built device type,
causing QEMU to abort.

Grey Divider

Tip of the day
💡 Did you know, you can commit Qodo's fix in one click with committable suggestions (GitHub & GitLab)

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

…C bus

galaxycore-sensor and ingenic-ov2735 take the image-sensor interface from
the decoders they already had, so a GalaxyCore part picked on infinity3
gets a picture instead of grey statistics.  They report no frame length
or window: the ISP takes those as unset.

rtc= on a sigmastar machine with no I2C bus (ssr621q, ssd202d, ssd201)
was accepted and did nothing, even with a bad name: it is refused now,
as sensor= is.  setup.sh's repair loop selects DS1338 for an existing
SIGMASTAR block too.
@dimerr

dimerr commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks, all three reproduced and fixed in the latest commit on this branch.

  1. GalaxyCore on the ISP: fixed. galaxycore-sensor and ingenic-ov2735 now implement image-sensor from the decoders they already had. They report rows and gain, and leave frame length and window unset, which the ISP accepts. No firmware here drives a GalaxyCore part on infinity3, so this is covered by a test that the types implement the interface, not by rendering a frame. The other Sony models, hisi-mis2006 and hisi-sp2305 have no exposure decode and stay as they are; that's now stated in CLAUDE.md and the PR description rather than guessed at.
  2. rtc= on machines with no I2C bus: fixed. It was silently ignored, even with a bad name (ssr621q,rtc=foo booted). It's now refused on those machines, with a test.
  3. DS1338 in the repair loop: fixed. Severity was lower than stated: other ARM boards select DS1338, so arm-softmmu already had it and nothing aborts today, but the block should say what it needs.

Re-tested: all 20 device suites, plus ym200j, ipcinfo with sensor=gc2053 on hi3516ev300 and the t31 boot.

@dimerr
dimerr merged commit db5f34a into OpenIPC:master Nov 4, 2026
41 checks passed
@dimerr
dimerr deleted the image-sensor-catalogue branch November 4, 2026 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant